#!/bin/bash
# 
# This script is called with the following arguments:
#	Arg	Name			Example
#	$1	Common action		common_action
#	$2	Monitor path		/home/user1
#	$3	Relative path		/file
#	$4	Absolute path		/home/user1/file
#	$5	Is directory		YES
#	$6	Synchronize path	/home/user2
#	$7	Cookie			2348
#	$8	Temp path		/home/user2/.inotify-sync
#	$9	Custom log		../log/sample.custom.log
#	$10	Error log		../log/sample.error.log
#	$11	Log enable		YES

MONITOR_PATH="$2"
RELATIVE_PATH="$3"
ABSOLUTE_PATH="$4"
IS_DIRECTORY="$5"
SYNC_PATH="$6"
COOKIE="$7"
TEMP_PATH="$8"
CUSTOM_LOG="$9"
ERROR_LOG="${10}"
LOG_ENABLE="${11}"

if [ "X$LOG_ENABLE" != "XNO" ]
then
	echo "========== Inotify Event Log =============" >> $CUSTOM_LOG
	echo "\$EVENT_TYPE=$EVENT_TYPE" >> $CUSTOM_LOG
	echo "\$MONITOR_PATH=$MONITOR_PATH" >> $CUSTOM_LOG
	echo "\$RELATIVE_PATH=$RELATIVE_PATH" >> $CUSTOM_LOG
	echo "\$ABSOLUTE_PATH=$ABSOLUTE_PATH" >> $CUSTOM_LOG
	echo "\$IS_DIRECTORY=$IS_DIRECTORY" >> $CUSTOM_LOG
	echo "\$SYNC_PATH=$SYNC_PATH" >> $CUSTOM_LOG
	echo "\$COOKIE=$COOKIE" >> $CUSTOM_LOG
	echo "\$TEMP_PATH=$TEMP_PATH" >> $CUSTOM_LOG
	echo "==========================================" >> $CUSTOM_LOG
fi
